ArcPad Scripting Object Model
Create New Shapefile
Send Feedback
ArcPad Scripting Object Model Reference > ArcPad Scripting Samples > Create New Shapefile

Glossary Item Box

Description:

This sample creates a new point shapefile and adds it to the current map.

How to use:

  1. Create a new map or open an existing map.
  2. Paste the JScript or VBScript code into the Script dialog box (depending on which language is set as the default scripting language).
  3. Click/Tap the Execute icon.

JScript

Copy Code
function CreateNewShapeFile()
{
  var pRS, strCurrDir;
  // create the recordset object
  pRS = Application.CreateAppObject ("RecordSet");
  // get the map and data path
  strCurrDir = Preferences.Properties("DataPath");
  // create a shapefile and add some fields
  pRS.Create (strCurrDir + "\\NewShapefile.shp", apShapePoint);
  pRS.Fields.Append ("ID", apFieldNumeric, 4, 0);
  pRS.Fields.Append ("NAME", apFieldCharacter, 30, 0);
  // add the new shapefile to the map
  Map.AddLayerFromFile (strCurrDir + "\\NewShapefile.shp");
  // free objects
  pRS = null;
}
CreateNewShapeFile();

VBScript

Copy Code
Sub CreateNewShapeFile()
  Dim pRS, strCurrDir
  '++ create the recordset object
  Set pRS = Application.CreateAppObject ("RecordSet")
  '++ get the map and data path
  strCurrDir = Preferences.Properties("DataPath")
  '++ create a shapefile and add some fields
  Call pRS.Create (strCurrDir & "\NewShapefile.shp" , apShapePoint)
  Call pRS.Fields.Append ("ID", apFieldNumeric, 4, 0)
  Call pRS.Fields.Append ("NAME", apFieldCharacter, 30, 0)
  '++ add the new shapefile to the map
  Call Map.AddLayerFromFile (strCurrDir & "\NewShapefile.shp")
  '++ free objects
  Set pRS = Nothing
End Sub
Call CreateNewShapeFile()
©2012. All Rights Reserved.